package com.qf.git04.demo01;

import cn.hutool.core.io.IoUtil;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;

@WebServlet("/draw")
public class ShowImage extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取cookie
        Cookie[] cookies = req.getCookies();
        for (Cookie cookie : cookies) {
            if("gitcookie".equals(cookie.getName())){
                InputStream is = new FileInputStream("D:\\1.jpg");
                ServletOutputStream out = resp.getOutputStream();
                IoUtil.copy(is,out,8192);
            }

        }
    }
}
